package cn.kgc.controller.logic.document;

import cn.kgc.pojo.Document;
import cn.kgc.pojo.User;
import cn.kgc.service.document.gth_documentServer;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/echarts")
public class Echarts {
    @Resource
    private gth_documentServer server;

    @RequestMapping("/ech")
    public String ech(){
        return "document/bar-background";
    }

    @RequestMapping("/background")
    @ResponseBody
    public String background(Integer u_id, HttpServletRequest request){
        HttpSession session = request.getSession();
        User user = (User)session.getAttribute("user");
        u_id = user.getId();
        List<Document> echar = server.echar(u_id);
        return JSON.toJSONString(echar);
    }
}
